﻿using System;
using System.Text;
using System.Windows.Forms;
using NetExceptionReporter.Extensions;

namespace NetExceptionReporter
{
    [Serializable()]
    public class DefaultExceptionWindowBehavior : IExceptionWindowBehavior
    {
        public virtual string Title
        {
            get { return null; }
        }

        public virtual ExceptionWindowStyle Style
        {
            get { return ExceptionWindowStyle.Default; }
        }

        public virtual void OnException(Exception e, out bool displayExceptionWindow)
        {
            displayExceptionWindow = true;
        }

        public virtual string OnComposeDetailedDescription(Exception e)
        {
            StringBuilder errorMessage = new StringBuilder();

            errorMessage.Append("Program: " + Application.ProductName + " [ " + ExceptionReporter.EntryAssemblyPath + " ]" +
               Environment.NewLine +
               Environment.NewLine);

            errorMessage.Append("Timestamp: " + DateTime.UtcNow.ToString("MM/dd/yyyy HH:mm:ss:ffff UTC") +
                Environment.NewLine +
                Environment.NewLine);

            errorMessage.Append(e.ToDisplayString());

            return errorMessage.ToString();
        }

        public virtual void OnReportException(Exception e)
        {
            /* Override to provide code which handles reporting the exception */
        }
    }
}